<script lang="ts" setup>
import type { VbenFormProps } from '#/adapter/form';
import type { VxeGridProps } from '#/adapter/vxe-table';

import { Button, Modal } from 'ant-design-vue';
import { Page } from '@vben/common-ui';
import { useVbenVxeGrid } from '#/adapter/vxe-table';

import { useRouter } from 'vue-router';

const router = useRouter();

interface RowType {
  category: string;
  color: string;
  id: string;
  department: string;
  title: string;
  staffno: string;
}

const formOptions: VbenFormProps = {
  // 默认展开
  collapsed: false,
  schema: [
    {
      component: 'Input',
      defaultValue: '',
      fieldName: 'category',
      label: 'ID',
    },
    {
      component: 'Input',
      fieldName: 'productName',
      label: '福利ID',
    },
    {
      component: 'Input',
      fieldName: 'productName',
      label: '日期',
    },
    {
      component: 'Input',
      fieldName: 'productName',
      label: '员工姓名',
    },
    {
      component: 'Input',
      fieldName: 'productName',
      label: '部门',
    },
    {
      component: 'Input',
      fieldName: 'productName',
      label: '领取状态',
    },
  ],
  // 控制表单是否显示折叠按钮
  showCollapseButton: true,
  // 按下回车时是否提交表单
  submitOnEnter: false,
};

const gridOptions: VxeGridProps<RowType> = {
  checkboxConfig: {
    highlight: true,
    labelField: 'name',
  },
  columns: [
    { field: 'id', title: '员工ID' },
    { field: 'category', title: '福利ID' },
    { field: 'title', title: '员工姓名' },
    { field: 'staffno', title: '工号' },
    { field: 'department', title: '部门' },
    { field: 'time', title: '领取时间' },
    { field: 'status', title: '领取状态' },
  ],
  height: 'auto',
  keepSource: false,
  pagerConfig: {},
  data: [
    {
      id: '1',
      category: '1',
      title: '张三',
      staffno: '0010',
      department: '财务部',
      time: '10月20日 15:20',
      status: '已领取',
    },
    {
      id: '2',
      category: '1',
      title: '李四',
      staffno: '0011',
      department: '人事部',
      time: '-',
      status: '未领取',
    },
  ],
};

const [Grid] = useVbenVxeGrid({ formOptions, gridOptions });

function routerPush(name: string, id: number) {
  // 这里就是路由跳转，也可以用path
  router.push({ name: name, params: { id } });
}
</script>

<template>
  <Page auto-content-height>
    <Grid>
      <template #toolbar-tools>
        <Button class="mr-2" type="primary">导出</Button>
      </template>
    </Grid>
  </Page>
</template>
